//
//  NewSettingViewController.m
//  wangzhe
//
//  Created by 李 佳伟 on 2018/3/7.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "NewSettingViewController.h"
#import "JTCSM.h"
#import "MyInfoView.h"
#import "NewChangePhoneNumberViewController.h"
#import "NewZhangHaoAnQuanViewController.h"
#import "NewBanBenInfoViewController.h"
static CGFloat myinfoHeight = 50;
@interface NewSettingViewController ()<UIAlertViewDelegate>
{
    UIScrollView *backScrollV;
}
@end

@implementation NewSettingViewController

- (void)gotBack{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [df isRemoveTarbar:YES];
    self.navigationController.navigationBar.hidden = NO;
    self.view.backgroundColor =[UIColor whiteColor];
    leftBarButtonItems_rightBarButtonItems *leftbtn = KCUSTOMNAVIGSTION_ALLOC;
    self.navigationItem.leftBarButtonItem = [leftbtn setBarButtonItemsImageName:@"fanhui.png" frame:KLeftBarButtonItemFrame_image target:self SEL:@selector(gotBack)];
    backScrollV = [[UIScrollView alloc]initWithFrame:CGRectMake(0, KagainChangeHeight, KCONTROLLERWith, KCONTROLLERHeight)];
    backScrollV.backgroundColor = RGBACOLOR(241, 241, 241, 1);
    backScrollV.userInteractionEnabled = YES;
    backScrollV.bounces = NO;
    backScrollV.showsVerticalScrollIndicator = NO;
    [self.view addSubview:backScrollV];
        [self layoutMyinfoView];
    
    
}

- (void)layoutMyinfoView{
    
    NSArray *array = @[@"更换登录手机号"];
   
    NSArray *array1 = @[@"账户安全",@"支付设置"];
   
    NSArray *array2 = @[@"通知设置",@"清理缓存",@"版本介绍"];
    
     NSArray *array3 = @[@"给我评价"];
   
    [df lineViewWithHeightofTop:10 superView:backScrollV spacing:0 color:RGBACOLOR(241, 241, 241, 1) lineHeight:10];
    for (int i = 0; i < array.count; i++) {
        MyInfoView *view1 = [[MyInfoView alloc]initWithFrame:CGRectMake(0, 10+myinfoHeight*i, KCONTROLLERWith, myinfoHeight) imagename:nil title:array[i] placeholder:nil isShowLabel:ImageViewType radioBtnIndex:0 GroupId:@""];
        view1.tag = 100+i;
        view1.userInteractionEnabled = YES;
        [df addTapGestureRecognizerWithTarget:self action:@selector(gotoVC:) andaddView:view1];
        [backScrollV addSubview:view1];
        view1.lineView.hidden = YES;
        
    }
    [df lineViewWithHeightofTop:myinfoHeight*array.count+20 superView:backScrollV spacing:0 color:RGBACOLOR(241, 241, 241, 1) lineHeight:10];
    for (int i = 0; i < array1.count; i++) {
        MyInfoView *view2 = [[MyInfoView alloc]initWithFrame:CGRectMake(0, myinfoHeight*array.count+20+myinfoHeight*i, KCONTROLLERWith, myinfoHeight) imagename:nil title:array1[i] placeholder:nil isShowLabel:ImageViewType radioBtnIndex:0 GroupId:@""];
        view2.tag = 200+i;
        view2.userInteractionEnabled = YES;
        [df addTapGestureRecognizerWithTarget:self action:@selector(gotoVC:) andaddView:view2];
        [backScrollV addSubview:view2];
        if (i ==1) {
            view2.lineView.hidden = YES;
        }
    }
    [df lineViewWithHeightofTop:myinfoHeight*(array.count+array1.count)+30 superView:backScrollV spacing:0 color:RGBACOLOR(241, 241, 241, 1) lineHeight:10];
   
    for (int i = 0; i < array2.count; i++) {
         MyInfoView *view3 = [[MyInfoView alloc]initWithFrame:CGRectMake(0,myinfoHeight*(array.count+array1.count)+30+myinfoHeight*i, KCONTROLLERWith, myinfoHeight) imagename:nil title:array2[i] placeholder:nil isShowLabel:ImageandlabelViewType radioBtnIndex:0 GroupId:@""];
        view3.tag = 300+i;
        view3.userInteractionEnabled = YES;
        if (i == 1) {
            view3.footerLabel.text = @"2.87M";
        }
        if (i == 2) {
            view3.footerLabel.text = @"v2.0.0";
        }
        view3.footerLabel.textColor = [df colorWithHexString:@"666666" alpha:1];
        [df addTapGestureRecognizerWithTarget:self action:@selector(gotoVC:) andaddView:view3];
        [backScrollV addSubview:view3];
        if (i == 2) {
            view3.lineView.hidden = YES;
        }
        
        
    }
    
    [df lineViewWithHeightofTop:myinfoHeight*(array.count+array1.count+array2.count)+40 superView:backScrollV spacing:0 color:RGBACOLOR(241, 241, 241, 1) lineHeight:10];
    MyInfoView *view4;
    for (int i = 0; i < array3.count; i++) {
        view4 = [[MyInfoView alloc]initWithFrame:CGRectMake(0,myinfoHeight*(array.count+array1.count+array2.count)+40+myinfoHeight*i, KCONTROLLERWith, myinfoHeight) imagename:nil title:array3[i] placeholder:nil isShowLabel:ImageViewType radioBtnIndex:0 GroupId:@""];
        view4.tag = 400+i;
        view4.lineView.hidden = YES;
        view4.userInteractionEnabled = YES;
        [df addTapGestureRecognizerWithTarget:self action:@selector(gotoVC:) andaddView:view4];
        [backScrollV addSubview:view4];
        [backScrollV setContentSize:CGSizeMake(KCONTROLLERWith, KVIEW_Y(view4))];
        
    }
    
    UIButton *tijiaobutton = [UIButton buttonWithType:UIButtonTypeCustom];
    tijiaobutton.frame = CGRectMake(0, KVIEW_Y(view4)+30, KCONTROLLERWith, 50);
    [tijiaobutton addTarget:self action:@selector(tijiao) forControlEvents:UIControlEventTouchUpInside];
    tijiaobutton.backgroundColor = [UIColor whiteColor];
    [tijiaobutton setTitleColor:RGBACOLOR(51, 51, 51, 1) forState:UIControlStateNormal];
    [tijiaobutton setTitle:@"退出登录" forState:UIControlStateNormal];
    [backScrollV addSubview:tijiaobutton];
    
}

- (void)gotoVC:(UITapGestureRecognizer *)tap{
    switch ([tap view].tag) {
        case 100:
            [self gotoNewChangePhoneNumberViewController];
            break;
        case 200:
            [self gotoZhanghaoAnQuanVC];
            break;
        case 302:
            [self gotoNewBanBenInfoViewController];
        default:
            break;
    }
}

- (void)gotoNewBanBenInfoViewController{
    NewBanBenInfoViewController *vc = [[NewBanBenInfoViewController alloc]init];
    vc.nameTitle = @"版本介绍";
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)gotoNewChangePhoneNumberViewController{
    NewChangePhoneNumberViewController *vc = [[NewChangePhoneNumberViewController alloc]init];
    vc.nameTitle = @"更换登录手机号";
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)gotoZhanghaoAnQuanVC{
    NewZhangHaoAnQuanViewController *vc = [[NewZhangHaoAnQuanViewController alloc]init];
    vc.nameTitle = @"账号安全";
    [self.navigationController pushViewController:vc animated:YES];
}


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (KAlertVTag+111 == alertView.tag) {
        if (buttonIndex ==0) {
            KUSERDEFAULTRemoveAll(KInfoKey);
            [df gotoLoginVC:self.navigationController];
        }
    }
}
- (void)tijiao{
    [df showAlertWithTitle:@"您确定退出登录" message:nil btn1:@"确定" btn2:@"取消" btn3:nil delegate:self tag:111];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
